x86/mm: Further restrict permissions on some virtual mappings
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 11 Apr 2017 15:34:58 +0000 (16:34 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 5 May 2017 08:54:28 +0000 (09:54 +0100)
commita5a5d1ee949d04d673573f8f59f6715edd171c57
tree120f8781a9121c151429cefc9782582a1b3b8517
parent040e1457c109185a5420e24203cad8e92f3caaca
x86/mm: Further restrict permissions on some virtual mappings

As originally reported, the Linear Pagetable slot maps 512GB of ram as RWX,
where the guest has full read access and a lot of direct or indirect control
over the written content.  It isn't hard for a PV guest to hide shellcode
here.

Therefore, increase defence in depth by auditing our current pagetable
mappings.

 * The regular linear, shadow linear, and per-domain slots have no business
   being executable (but need to be written), so are updated to be NX.
 * The Read Only mappings of the M2P (compat and regular) don't need to be
   writeable or executable.
 * The PV GDT mappings and bits of the directmap don't need to be executable.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: George Dunlap <george.dunlap@citrix.com>
Release-acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/x86/domain.c
xen/arch/x86/mm.c
xen/arch/x86/mm/hap/hap.c
xen/arch/x86/mm/shadow/multi.c
xen/arch/x86/x86_64/mm.c